<style>
/*网站监控报表*/

.data-count {
	background-color: #FAFAFA;
	border: #ddd 1px solid;
	height: 80px;
	width: 100%;
	margin-bottom: 15px;
}

.data-count-box {
	height: 100%;
	text-align: center;
	width: 49%;
	float: left;
}

.data-count-box:first-child {
	border-right: #ddd 1px solid;
}

.data-count-box .dname {
	color: #78797D;
	margin-top: 12px;
	margin-bottom: 10px;
}

.data-count-box .dval {
	color: #333;
}

.data-count-box .dval span {
	font-family: arial;
	color: #121313;
	font-size: 20px;
}

.data-count-all {
	background-color: #FAFAFA;
	border: #ddd 1px solid;
	width: 100%;
	margin-bottom: 15px;
	float: left;
}

.data-count-all .data-count-box {
	height: 100%;
	text-align: center;
	width: 25%;
	float: left;
	margin-bottom: 20px;
}

.table-auto-box {}

.lib-con {
	margin-bottom: 10px;
	width: 100%;
}

.divpre {
	padding: 9.5px;
	margin: 0 0 10px;
	font-size: 13px;
	line-height: 1.42857143;
	color: #333;
	word-break: break-all;
	word-wrap: break-word;
	background-color: #f6f6f6;
	border: 1px solid #ddd;
	border-radius: 4px;
	max-height: 100px;
	overflow: auto
}
.search-day{
	height:32px;
	margin-left:1px;
	margin-bottom:15px;
}
.search-day span{
	float:left;
	height:32px;
	line-height:30px;
	border:#ddd 1px solid;
	padding:0 20px;
	margin-left:-1px;
	cursor:pointer;
	position:relative;
}
.search-day span.cur{
	background-color:#20a53a;
	color:#fff;
}
.search-day span.cur input,.search-day span.cur em{
	color:#666;
}
.search-day span:last-child{
	padding:0;
}
.search-day span input{
	border: 0 none;
	height:30px;
	padding:0 10px;
	width:105px;
	background-image: url("");
	background-repeat:no-repeat;
	background-position:86px center;
}
.search-day span input:active{
	border:0 none;
}
.search-day span.cur input{
	color:#fff;
	background-color:#20a53a;
	background-image: url("");
}
.table .sitename, .filtertext {
    width: 190px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.site-all .data-count-box{
	width:20%
}
.total-open{
	position:absolute;
	top:16px;
	left:300px;
	line-height:32px
}
.site-log-open{
	position:absolute;
	top:14px;
	left:250px;
	line-height:32px
}
</style>
<div class="bt-form">
	<div class="bt-w-main">
		<div class="websitereport-con pd15" ></div>
	</div>
</div>
<script type="text/javascript" src="/static/js/echarts.min.js"></script>
<script type="text/javascript" src="/static/js/china.js"></script>
<script type="javascript/text">
			$('.layui-layer-page').css({ 'width': '900px' });
			webDataStats_day(); 
			$(".bt-w-menu p").click(function() {
				$(this).addClass("bgw").siblings().removeClass("bgw");
			})

			function html_decode(value) {
				return $('<div />').text(value).html();
			}
			//表格头固定
			function tableFixed(name){
				var tableName = document.querySelector('#'+name);
				tableName.addEventListener('scroll',scrollHandle);
			}
			function scrollHandle (e){
				var scrollTop = this.scrollTop;
				//this.querySelector('thead').style.transform = 'translateY(' + scrollTop + 'px)';
				$(this).find("thead").css({"transform":"translateY("+scrollTop+"px)","position":"relative","z-index":"1"});
			}
			//单站点监控概览
			function WebGeneralView(siteName,today) {
				var con = '<div class="search-day"><span class="cur" onclick="get_WebGeneralView(\''+siteName+'\',\''+getBeforeDate(0)+'\')">今日</span><span onclick="get_WebGeneralView(\''+siteName+'\',\''+getBeforeDate(1)+'\')">昨日</span><span class="last-span"><input id="date-select" type="text" value=""></span></div><div class="websitereport-day" style="height:260px"></div><ul class="help-info-text c7" style="margin-top:30px"><li>PV(PageView值)：用户每次打开网站页面被记录1次。用户多次打开同一页面，访问量值累计多次。此指标衡量网站访问量情况。</li><li>UV(独立访客)：访问您网站的上网电脑数量（以cookie为依据），此指标衡量独立访客数量情况。</li></ul>';
				$(".websitereport").html(con);
				get_WebGeneralView(siteName,getBeforeDate(0));
				$(".search-day span").not(".last-span").click(function(){
					$(this).addClass("cur").siblings().removeClass("cur");
				})
				laydate.render({
					elem: '#date-select',
					value: new Date(),
					max: 0,
					done: function(value, date, endDate){get_WebGeneralView(siteName,value);$("#date-select").val(value);$(".last-span").addClass("cur").siblings().removeClass("cur")}
				});
			}
			
			//指定日期数据
			function get_WebGeneralView(siteName,today){
				var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
				$.post('/plugin?action=a&name=total&s=get_total_bysite', {siteName:siteName,today:today}, function(rdata) {
					layer.close(loadT);
					var con = '<div class="data-count-all">\
							<div class="data-count-box" style="border:0 none"><p class="dname">当日流量</p><p class="dval"><span>' + ToSize(rdata.total.day_network) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">当日PV</p><p class="dval"><span title='+SectionToChinese(rdata.total.day_pv)+'>' + formatCurrency(rdata.total.day_pv) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">当日UV</p><p class="dval"><span title='+SectionToChinese(rdata.total.day_uv)+'>' + formatCurrency(rdata.total.day_uv) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">当日IP</p><p class="dval"><span title='+SectionToChinese(rdata.total.day_ip)+'>' + formatCurrency(rdata.total.day_ip) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">当日请求数</p><p class="dval"><span title='+SectionToChinese(rdata.total.day_request)+'>' + formatCurrency(rdata.total.day_request) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">POST请求</p><p class="dval"><span title='+SectionToChinese(rdata.total.day_post)+'>' + formatCurrency(rdata.total.day_post) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">GET请求</p><p class="dval"><span title='+SectionToChinese(rdata.total.day_get)+'>' + formatCurrency(rdata.total.day_get) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">PUT请求</p><p class="dval"><span title='+SectionToChinese(rdata.total.day_put)+'>' + formatCurrency(rdata.total.day_put) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">500错误</p><p class="dval"><span title='+SectionToChinese(rdata.total.day_500)+'>' + formatCurrency(rdata.total.day_500) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">502错误</p><p class="dval"><span title='+SectionToChinese(rdata.total.day_502)+'>' + formatCurrency(rdata.total.day_502) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">503错误</p><p class="dval"><span title='+SectionToChinese(rdata.total.day_503)+'>' + formatCurrency(rdata.total.day_503) + '</span></p></div>\
						</div>';
					$(".websitereport-day").html(con);
				});
			}
			
			//定义周期时间
			function getBeforeDate(n){
				var n = n;
				var d = new Date();
				var year = d.getFullYear();
				var mon=d.getMonth()+1;
				var day=d.getDate();
				if(day <= n){
					if(mon>1) {
					   mon=mon-1;
					}
					else {
					 year = year-1;
					 mon = 12;
					}
				}
				d.setDate(d.getDate()-n);
				year = d.getFullYear();
				mon=d.getMonth()+1;
				day=d.getDate();
				s = year+"-"+(mon<10?('0'+mon):mon)+"-"+(day<10?('0'+day):day);
				return s;
			}
			//数据格式化
			function formatCurrency(num) {
				num = num.toString().replace(/\$|\,/g,'');
				if(isNaN(num))
					num = "0";
				sign = (num == (num = Math.abs(num)));
				num = Math.floor(num*100+0.50000000001);
				num = Math.floor(num/100).toString();
				for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
				num = num.substring(0,num.length-(4*i+3))+','+
				num.substring(num.length-(4*i+3));
				return (((sign)?'':'-') + num);
			}
			//阿拉伯数字转换为简写汉字
			function SectionToChinese(Num) {
				for (i = Num.length - 1; i >= 0; i--) {
					Num = Num.replace(",", "")
					Num = Num.replace(" ", "")
				}    
				if (isNaN(Num)) {
					return;
				}
				//字符处理完毕后开始转换，采用前后两部分分别转换
				part = String(Num).split(".");
				newchar = "";
				//小数点前进行转化
				for (i = part[0].length - 1; i >= 0; i--) {
					if (part[0].length > 10) {
						return "";
					}
					tmpnewchar = ""
					perchar = part[0].charAt(i);
					switch (perchar) {
						case "0":  tmpnewchar = "零" + tmpnewchar;break;
						case "1": tmpnewchar = "一" + tmpnewchar; break;
						case "2": tmpnewchar = "二" + tmpnewchar; break;
						case "3": tmpnewchar = "三" + tmpnewchar; break;
						case "4": tmpnewchar = "四" + tmpnewchar; break;
						case "5": tmpnewchar = "五" + tmpnewchar; break;
						case "6": tmpnewchar = "六" + tmpnewchar; break;
						case "7": tmpnewchar = "七" + tmpnewchar; break;
						case "8": tmpnewchar = "八" + tmpnewchar; break;
						case "9": tmpnewchar = "九" + tmpnewchar; break;
					}
					switch (part[0].length - i - 1) {
						case 0: tmpnewchar = tmpnewchar; break;
						case 1: if (perchar != 0) tmpnewchar = tmpnewchar + "十"; break;
						case 2: if (perchar != 0) tmpnewchar = tmpnewchar + "百"; break;
						case 3: if (perchar != 0) tmpnewchar = tmpnewchar + "千"; break;
						case 4: tmpnewchar = tmpnewchar + "万"; break;
						case 5: if (perchar != 0) tmpnewchar = tmpnewchar + "十"; break;
						case 6: if (perchar != 0) tmpnewchar = tmpnewchar + "百"; break;
						case 7: if (perchar != 0) tmpnewchar = tmpnewchar + "千"; break;
						case 8: tmpnewchar = tmpnewchar + "亿"; break;
						case 9: tmpnewchar = tmpnewchar + "十"; break;
					}
					newchar = tmpnewchar + newchar;
				}   
				//替换所有无用汉字，直到没有此类无用的数字为止
				while (newchar.search("零零") != -1 || newchar.search("零亿") != -1 || newchar.search("亿万") != -1 || newchar.search("零万") != -1) {
					newchar = newchar.replace("零亿", "亿");
					newchar = newchar.replace("亿万", "亿");
					newchar = newchar.replace("零万", "万");
					newchar = newchar.replace("零零", "零");      
				}
				//替换以“一十”开头的，为“十”
				if (newchar.indexOf("一十") == 0) {
					newchar = newchar.substr(1);
				}
				//替换以“零”结尾的，为“”
				if (newchar.lastIndexOf("零") == newchar.length - 1) {
					newchar = newchar.substr(0, newchar.length - 1);
				}
				return newchar;
			}
			//站点统计日期选择
			function webDataStats_day(){
				var con = '<div class="search-day"><span class="cur" onclick="WebDataStats()">今日</span><span onclick="WebDataStats(\''+getBeforeDate(1)+'\')">昨日</span><span class="last-span"><input id="webdate-select" type="text" value=""></span></div><div class="data-count-all site-all"></div><div class="webDataStats-day"></div>';
				$(".websitereport-con").html(con);
				WebDataStats();
				$(".search-day span").not(".last-span").click(function(){
					$(this).addClass("cur").siblings().removeClass("cur");
				})
				laydate.render({
					elem: '#webdate-select',
					value: new Date(),
					max: 0,
					done: function(value, date, endDate){
						WebDataStats(value);
						$("#date-select").val(value);
						$(".last-span").addClass("cur").siblings().removeClass("cur");
					}
				});
			}
			//监控统计开关
			function close_total(today){
				var txt = "这会损失掉一些nginx/apache性能,是否开启监控统计?";
				var status = $("#close_total").prop("checked");
				if(status){
					txt = "是否关闭监控统计"
				}
				layer.confirm(txt,{title:"监控统计开关",icon:3,closeBtn:2,cancel:function(){
					if(status){
						$("#close_total").prop("checked",true);
					}
					else{
						$("#close_total").prop("checked",false);
					}
				}}, function() {
					$.get("/plugin?action=a&name=total&s=set_status",function(res){
						layer.msg(res.msg,{icon:res.status?1:2});
						setTimeout(function(){WebDataStats(today)},2000);
					})
				},function(){
					if(status){
						$("#close_total").prop("checked",true);
					}
					else{
						$("#close_total").prop("checked",false);
					}
				})
			}
			//站点统计
			function WebDataStats(today) {
				var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
				$.get('/plugin?action=a&name=total&s=get_sites',{today:today}, function(res) {
					layer.close(loadT);
					if(res.status === false){
						layer.closeAll()
						layer.msg(res.msg,{icon:2})
						return;
					}
					var tbody = '';
					var rdata = res.data;
					var total_pv =0,total_uv = 0 ,total_ip = 0,total_flow = 0,total_req = 0;
					for (var i = 0; i < rdata.length; i++) {
						total_pv +=rdata[i].total.day_pv;
						total_uv +=rdata[i].total.day_uv;
						total_ip +=rdata[i].total.day_ip;
						total_flow +=rdata[i].total.day_network;
						total_req +=rdata[i].total.day_request;
						tbody += '<tr>\
										<td><a href="javascript:WebsiteReport(\'' + rdata[i].site_name + '\')" class="sitename btlink" title="' + rdata[i].site_name + '" style="width:120px">' + rdata[i].site_name + '</a></td>\
										<td title='+SectionToChinese(rdata[i].total.day_pv)+'>' + formatCurrency(rdata[i].total.day_pv) + '</td>\
										<td title='+SectionToChinese(rdata[i].total.day_uv)+'>' + formatCurrency(rdata[i].total.day_uv) + '</td>\
										<td title='+SectionToChinese(rdata[i].total.day_ip)+'>' + formatCurrency(rdata[i].total.day_ip) + '</td>\
										<td>' + ToSize(rdata[i].total.day_network) + '</td>\
										<td>' + ToSize(rdata[i].total.network) + '</td>\
										<td title='+SectionToChinese(rdata[i].total.day_request)+'>' + formatCurrency(rdata[i].total.day_request) + '</td>\
										<td title='+SectionToChinese(rdata[i].total.request)+'>' + formatCurrency(rdata[i].total.request) + '</td>\
										<td title='+SectionToChinese(rdata[i].total.day_spider)+'>' + formatCurrency(rdata[i].total.day_spider) + '</td>\
										<td>\
											<div class="ssh-item" style="margin-left:0">\
												<input class="btswitch btswitch-ios" id="close_' + rdata[i].site_name + '" type="checkbox" ' + (rdata[i].open ? 'checked' : '') + '>\
												<label class="btswitch-btn" for="close_' + rdata[i].site_name + '" onclick="set_site_state(\'' + rdata[i].site_name + '\',\'' + !rdata[i].open + '\')" style="width:2em;height:1.2em"></label>\
											</div>\
										</td>\
										<td><a href="javascript:WebsiteReport(\'' + rdata[i].site_name + '\')" class="btlink">详情</a></td>\
									</tr>'
					}
					var site_all = '<div class="total-open">\
							<span class="pull-left">监控统计</span>\
							<div class="ssh-item pull-right">\
							<input class="btswitch btswitch-ios" id="close_total" type="checkbox" '+(res.open?'checked':'')+'>\
							<label class="btswitch-btn" for="close_total" onclick="close_total(\''+today+'\')"></label>\
							</div>\
							</div>\
							<div class="data-count-box" style="border:0 none"><p class="dname">浏览量(PV)</p><p class="dval"><span title='+SectionToChinese(total_pv)+'>'+formatCurrency(total_pv)+'</span></p></div>\
							<div class="data-count-box"><p class="dname">访客数(UV)</p><p class="dval"><span title='+SectionToChinese(total_uv)+'>'+formatCurrency(total_uv)+'</span></p></div>\
							<div class="data-count-box"><p class="dname">IP数</p><p class="dval"><span title='+SectionToChinese(total_ip)+'>'+formatCurrency(total_ip)+'</span></p></div>\
							<div class="data-count-box"><p class="dname">流量</p><p class="dval"><span>'+ToSize(total_flow)+'</span></p></div>\
							<div class="data-count-box"><p class="dname">请求</p><p class="dval"><span title='+SectionToChinese(total_req)+'>'+formatCurrency(total_req)+'</span></p></div>';
					var con = '<div class="divtable">\
							<div id="total_box" style="max-height:370px;overflow:auto;border:#ddd 1px solid">\
							<table class="table table-hover" style="border:none">\
								<thead>\
									<tr>\
										<th>网站名称</th>\
										<th>今日PV</th>\
										<th>今日UV</th>\
										<th>今日IP</th>\
										<th>今日流量</th>\
										<th>总流量</th>\
										<th>今日请求</th>\
										<th>总请求</th>\
										<th>蜘蛛</th>\
										<th>状态</th>\
										<th>详情</th>\
									</tr>\
								</thead>\
								<tbody id="total_site_list">' + tbody + '</tbody>\
							</table>\
						</div></div>';
					$(".webDataStats-day").html(con);
					tableFixed("total_box");
					$(".site-all").html(site_all);
					if(res.open == false){
						$(".webDataStats-day .ssh-item input").prop({"checked":false,"disabled":"disabled"});
						$(".webDataStats-day .ssh-item .btswitch-btn").removeAttr("onclick");
					}
				});
			}


			function set_site_state(siteName, s_value) {
				$.post('/plugin?action=a&name=total&s=set_site_value', { siteName: siteName, s_key: 'open', s_value: s_value }, function(rdata) {
					layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 })
				})
			}

			//网站监控报表
			function WebsiteReport(siteName) {
				layer.open({
					type: 1,
					title: "网站监控报表【" + siteName + '】',
					area: '900px',
					closeBtn: 2,
					shadeClose: false,
					content: '<div class="bt-form">\
						<div class="bt-w-main" style="height:585px">\
							<div class="bt-w-menu">\
								<p class="bgw" onclick="WebGeneralView(\'' + siteName + '\')">监控概览</p>\
								<p onclick="WebFlowStats(\'' + siteName + '\')">流量统计</p>\
								<p onclick="SEOStats(\'' + siteName + '\')">蜘蛛统计</p>\
								<p onclick="show_error_log(\'' + siteName + '\')">错误日志</p>\
								<p onclick="AgentStass(\'' + siteName + '\')">客户端</p>\
								<p onclick="TakeoverLog(\'' + siteName + '\')">网站日志</p>\
							</div>\
							<div class="bt-w-con pd15">\
								<div class="websitereport" id="_content" style="height: 555px"></div>\
							</div>\
						</div>\
					</div>'
				});
				var today = '';
				WebGeneralView(siteName);
				$(".bt-w-menu p").click(function() {
					$(this).addClass("bgw").siblings().removeClass("bgw");
				})
			}

			//流量统计
			function WebFlowStats(siteName) {
				var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
				$.post('/plugin?action=a&name=total&s=get_site_network_all', { siteName: siteName }, function(rdata) {
					layer.close(loadT);
					var tbody = '';
					if(rdata.days == ''){
						tbody = '<tr><td colspan="12">暂无数据</td></tr>'
					}
					for (var i = 0; i < rdata.days.length; i++) {
						tbody += '<tr>\
										<td>' + rdata.days[i].date + '</td>\
										<td>' + ToSize(rdata.days[i].size) + '</td>\
										<td title='+SectionToChinese(rdata.days[i].request)+'>' + formatCurrency(rdata.days[i].request) + '</td>\
										<td title='+SectionToChinese(rdata.days[i].pv)+'>' + formatCurrency(rdata.days[i].pv) + '</td>\
										<td title='+SectionToChinese(rdata.days[i].uv)+'>' + formatCurrency(rdata.days[i].uv) + '</td>\
										<td title='+SectionToChinese(rdata.days[i].ip)+'>' + formatCurrency(rdata.days[i].ip) + '</td>\
										<td title='+SectionToChinese(rdata.days[i].post)+'>' + formatCurrency(rdata.days[i].post) + '</td>\
										<td title='+SectionToChinese(rdata.days[i].get)+'>' + formatCurrency(rdata.days[i].get) + '</td>\
										<td title='+SectionToChinese(rdata.days[i]['500'])+'>' + formatCurrency(rdata.days[i]['500']) + '</td>\
										<td title='+SectionToChinese(rdata.days[i]['502'])+'>' + formatCurrency(rdata.days[i]['502']) + '</td>\
										<td title='+SectionToChinese(rdata.days[i]['503'])+'>' + formatCurrency(rdata.days[i]['503']) + '</td>\
										<td><a class="btlink" onclick="get_total_day(\'' + siteName + '\',\'' + rdata.days[i].date + '\')">详细</a></td>\
									</tr>'
					}

					var con = '<div class="data-count">\
							<div class="data-count-box"><p class="dname">总流量</p><p class="dval"><span>' + ToSize(rdata.total_size) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">总请求</p><p class="dval"><span title='+SectionToChinese(rdata.total_request)+'>' + formatCurrency(rdata.total_request) + '</span></p></div>\
						</div>\
						<div class="divtable">\
							<div id="WebFlowStats" style="max-height: 409px; overflow: auto; border:#ddd 1px solid">\
							<table class="table table-hover" style="border:none">\
								<thead>\
									<tr>\
										<th>日期</th>\
										<th>流量</th>\
										<th>请求</th>\
										<th>PV</th>\
										<th>UV</th>\
										<th>IP</th>\
										<th>POST</th>\
										<th>GET</th>\
										<th>500</th>\
										<th>502</th>\
										<th>503</th>\
										<th>操作</th>\
									</tr>\
								</thead>\
								<tbody>' + tbody + '</tbody>\
							</table>\
							</div>\
						</div>';
					$(".websitereport").html(con);
					tableFixed("WebFlowStats")
				});
			}

			//取指定日期的记录
			function get_total_day(siteName, day) {
				//请求数
				layer.open({
					type: 1,
					title:'请求数统计',
					area: '800px',
					closeBtn: 2,
					shadeClose: false,
					content: '<div class="bt-form">\
						<div class="bt-w-main">\
							<div class="bt-w-menu flow_group">\
								<p class="bgw">请求数统计</p>\
								<p >流量统计</p>\
							</div>\
							<div class="bt-w-con pd15" id="flow_chart" style="height:550px;width:660px;">\
							</div>\
						</div>\
					</div>'
				});
				echarts_flow_chart('request_info',{siteName:siteName,day:day});
				$('.flow_group p').click(function(){
					$(this).addClass('bgw').siblings().removeClass('bgw');
					if($(this).index() == 0){
						echarts_flow_chart('request_info',{siteName:siteName,day:day});
					}else if($(this).index() == 1){
						echarts_flow_chart('flow_info',{siteName:siteName,day:day});
					}
				});
			}
			function echarts_flow_chart(className,param){
				var my_flow_chart = echarts.init(document.getElementById('flow_chart'));
				var  option = {};
				switch (className) {
					case 'request_info':
							var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
							$.post('/plugin?action=a&name=total&s=get_site_total_byday', { siteName: param.siteName, s_day: param. day, s_type: 'request' }, function(rdata) {
								layer.close(loadT);
								var rdata_list = rdata;
								var xData = [],all_arry = [],uv_arry = [],ip_arry = [],pv_arry = [],post_arry = [],get_arry = [],_500_arry = [],_501_arry = [], _503_arry = [],else_arry = [];
								for(var i = 0; i<rdata_list.length;i++){
									if(rdata_list[i]['500'] == undefined) rdata_list[i]['500'] = 0;
									if(rdata_list[i]['501'] == undefined) rdata_list[i]['501'] = 0;
									if(rdata_list[i]['503'] == undefined) rdata_list[i]['503'] = 0;
									if(rdata_list[i]['uv'] == undefined) rdata_list[i]['uv'] = 0;
									var all_num = 0,else_num = 0;
									$.each(rdata_list[i],function(j,v){
										if(j != 'key'){
											all_num += v;
										}
										if(j != 'key' && j != 'ip' && j != 'pv' && j != 'GET' && j != 'POST' && j != '500' && j != '501' && j != '503'){
											else_num += v;
										}
									});
									
									xData.push(rdata_list[i].key+':00');
									all_arry.push(all_num);
									uv_arry.push(rdata_list[i].uv);
									ip_arry.push(rdata_list[i].ip);
									pv_arry.push(rdata_list[i].pv);

									post_arry.push(rdata_list[i].POST);
									get_arry.push(rdata_list[i].GET);
									_500_arry.push(rdata_list[i]['500']);
									_501_arry.push(rdata_list[i]['501']);
									_503_arry.push(rdata_list[i]['503']);
									else_arry.push(else_num);
								}
								option = {
									title: {
									    text: '请求数统计',
									    left: '50%',
									    textAlign: 'center',
									},
									tooltip: {
										trigger: 'axis',
										axisPointer: {
											type: 'cross'
										}
									},
									grid:{
										height:'330',
										top:'24%',
									},
									legend: {
										data:['总请求','PV','UV','IP','POST','GET','500','501','503','其他'],
										top:'10%',
										selected: {
											'总请求': false,
											'UV': false,
											'IP': false,
											'PV': false,
											'POST': false,
											'GET': false,
											'其他': false
										}
									},
									xAxis: {
										type: 'category',
										data: xData,
										axisLine:{
											lineStyle:{
												color:"#666"
											}
										}
									},
									yAxis: {
										type: 'value',
										name: '单位/个',
										boundaryGap: [0, '100%'],
										splitLine:{
											lineStyle:{
												color:"#ddd"
											}
										},
										axisLine:{
											lineStyle:{
												color:"#666"
											}
										}
									},
									dataZoom: [{
										type: 'inside',
										start: 0,
										end: 100,
										zoomLock:true
									}, {
										start: 0,
										end: 100,
										handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
										handleSize: '80%',
										handleStyle: {
											color: '#fff',
											shadowBlur: 3,
											shadowColor: 'rgba(0, 0, 0, 0.6)',
											shadowOffsetX: 2,
											shadowOffsetY: 2
										}
									}],
									series: [
										{
											name:'总请求',
											type:'bar',
											itemStyle: {
												normal: {
													color: '#cde5ff'
												}
											},
											barMaxWidth:'26px',
											data: all_arry
										},
										{
											name:'PV',
											type:'line',
											smooth:true,
											symbol: 'circle',
											sampling: 'average',
											itemStyle: {
												normal: {
													color: '#32c5e9'
												}
											},
											data: pv_arry
										},
										{
											name:'UV',
											type:'line',
											smooth:true,
											symbol: 'circle',
											sampling: 'average',
											itemStyle: {
												normal: {
													color: '#65E94E'
												}
											},
											data: uv_arry
										},
										{
											name:'IP',
											type:'line',
											smooth:true,
											symbol: 'circle',
											sampling: 'average',
											itemStyle: {
												normal: {
													color: '#37a2da'
												}
											},
											data: ip_arry
										},
										{
											name:'POST',
											type:'line',
											smooth:true,
											symbol: 'circle',
											sampling: 'average',
											itemStyle: {
												normal: {
													color: '#9fe6b8'
												}
											},
											data: post_arry
										},
										{
											name:'GET',
											type:'line',
											smooth:true,
											symbol: 'circle',
											sampling: 'average',
											itemStyle: {
												normal: {
													color: '#ffdb5c'
												}
											},
											data: get_arry
										},
										{
											name:'500',
											type:'line',
											smooth:true,
											symbol: 'circle',
											sampling: 'average',
											itemStyle: {
												normal: {
													color: '#ff9f7f'
												}
											},
											data: _500_arry
										},
										{
											name:'501',
											type:'line',
											smooth:true,
											symbol: 'circle',
											sampling: 'average',
											itemStyle: {
												normal: {
													color: '#fb7293'
												}
											},
											data: _501_arry
										},
										{
											name:'503',
											type:'line',
											smooth:true,
											symbol: 'circle',
											sampling: 'average',
											itemStyle: {
												normal: {
													color: '#e062ae'
												}
											},
											data: _503_arry
										},
										 {
										 	name:'其他',
										 	type:'line',
										 	smooth:true,
										 	symbol: 'circle',
										 	sampling: 'average',
										 	itemStyle: {
										 		normal: {
										 			color: '#e690d1'
										 		}
										 	},
										 	data: else_arry
										 }
									]
								};
								my_flow_chart.setOption(option,true);
							});
						break;
					case 'flow_info':
					//流量
					var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
					$.post('/plugin?action=a&name=total&s=get_site_total_byday', { siteName: param.siteName, s_day:param. day, s_type: 'network' }, function(rdata) {
						layer.close(loadT);
						var xdata = [],flow_arry = [],unit ="";
						for(var i = 0 ; i<rdata.length; i++){
								xdata.push(rdata[i].key+':00');
								flow_arry.push(ToSize(rdata[i].value));
						}
						function ToSize(a) {
							var d = [" B", " KB", " MB", " GB", " TB", " PB"];
							var e = 1024;
							for(var b = 0; b < d.length; b++) {
								unit = d[b];
								if(a < e) {
									return(b == 0 ? a : a.toFixed(2));
								}
								a /= e
							}
						}
						option = {
							title: {
							    text: '流量统计',
							    left: '50%',
							    textAlign: 'center',
							},
							tooltip: {
								trigger: 'axis',
								axisPointer: {
									type: 'cross',
									label: {
						                backgroundColor: '#6a7985'
						            }
								},
								formatter:'{b}</br>{a} : {c}'+ unit
							},
							grid:{
								height:'330',
								top:'24%',
							},
							legend: {
								data:['流量'],
								top:'10%'
							},
							xAxis: {
								type: 'category',
								boundaryGap: false,
								data: xdata,
								axisLine:{
									lineStyle:{
										color:"#666"
									}
								}
							},
							yAxis: {
								type: 'value',
								name: unit + '/h',
								boundaryGap: [0, '100%'],
								splitLine:{
									lineStyle:{
										color:"#ddd"
									}
								},
								axisLine:{
									lineStyle:{
										color:"#666"
									}
								}
							},
							dataZoom: [{
								type: 'inside',
								start: 0,
								end: 100,
								zoomLock:true
							}, {
								start: 0,
								end: 100,
								handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
								handleSize: '80%',
								handleStyle: {
									color: '#fff',
									shadowBlur: 3,
									shadowColor: 'rgba(0, 0, 0, 0.6)',
									shadowOffsetX: 2,
									shadowOffsetY: 2
								}
							}],
							series: [
								{
									name:'流量',
									type:'line',
									smooth:true,
									symbol: 'circle',
									sampling: 'average',
									itemStyle: {
										normal: {
											color: '#8dc1a9'
										}
									},
									data: flow_arry
								},
							]
						};
						my_flow_chart.setOption(option,true);
					});
						break;
					default:
						// statements_def
						break;
				}
			}
			//SEO统计
			function SEOStats(siteName) {
				var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
				$.post('/plugin?action=a&name=total&s=get_site_total_byspider', { siteName: siteName }, function(rdata) {
					layer.close(loadT);
					var tbody = '';
					if(rdata.days == ''){
						tbody = '<tr><td colspan="12">暂无数据</td></tr>'
					}
					for (var i = 0; i < rdata.days.length; i++) {
						var s_total = s_baidu = s_360 = s_google = s_sogou = s_bing = s_yahoo = s_soso = s_yisou = s_other = 0;
						var s_date = rdata.days[i].date;
						$.each(rdata.days[i], function(k, v) {
							if (k == 'date') return;
							s_total += v;
							if (k.indexOf('Baidu') != -1) {
								s_baidu += v
							} else if (k.indexOf('Yahoo') != -1) {
								s_yahoo += v
							} else if (k.indexOf('360') != -1) {
								s_360 += v
							} else if (k.indexOf('Sogou') != -1) {
								s_sogou += v
							} else if (k.indexOf('Google') != -1) {
								s_google += v
							} else if (k.indexOf('bing') != -1) {
								s_bing += v
							} else if (k.indexOf('Yisou') != -1) {
								s_yisou += v
							} else if (k.indexOf('Soso') != -1) {
								s_soso += v
							} else {
								s_other += v
							}
						});

						tbody += '<tr>\
										<td>' + s_date + '</td>\
										<td title='+SectionToChinese(s_baidu)+'>' + formatCurrency(s_baidu) + '</td>\
										<td title='+SectionToChinese(s_360)+'>' + formatCurrency(s_360) + '</td>\
										<td title='+SectionToChinese(s_google)+'>' + formatCurrency(s_google) + '</td>\
										<td title='+SectionToChinese(s_sogou)+'>' + formatCurrency(s_sogou) + '</td>\
										<td title='+SectionToChinese(s_bing)+'>' + formatCurrency(s_bing) + '</td>\
										<td title='+SectionToChinese(s_soso)+'>' + formatCurrency(s_soso) + '</td>\
										<td title='+SectionToChinese(s_yisou)+'>' + formatCurrency(s_yisou) + '</td>\
										<td title='+SectionToChinese(s_yahoo)+'>' + formatCurrency(s_yahoo) + '</td>\
										<td title='+SectionToChinese(s_other)+'>' + formatCurrency(s_other) + '</td>\
										<td title='+SectionToChinese(s_total)+'>' + formatCurrency(s_total) + '</td>\
										<td><a class="btlink" onclick="get_spider_bydate(\'' + siteName + '\',\'' + s_date + '\')">详细</a></td>\
									</tr>';
					}

					var con = '<div class="data-count">\
							<div class="data-count-box"><p class="dname">今日次数</p><p class="dval"><span title='+SectionToChinese(rdata.total_day)+'>' + formatCurrency(rdata.total_day) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">总次数</p><p class="dval"><span title='+SectionToChinese(rdata.total_all)+'>' + formatCurrency(rdata.total_all) + '</span></p></div>\
						</div>\
						<div class="divtable">\
							<div id="SEOStats_box" style="max-height:409px;overflow:auto;border:#ddd 1px solid">\
							<table class="table table-hover" style="border:none">\
								<thead>\
									<tr>\
										<th>日期</th>\
										<th>百度</th>\
										<th>360</th>\
										<th>google</th>\
										<th>搜狗</th>\
										<th>必应</th>\
										<th>Soso</th>\
										<th>神马</th>\
										<th>雅虎</th>\
										<th>其它</th>\
										<th>总次数</th>\
										<th>操作</th>\
									</tr>\
								</thead>\
								<tbody>' + tbody + '</tbody>\
							</table>\
							</div>\
						</div>';
					$(".websitereport").html(con);
					tableFixed("SEOStats_box");
				});
			}
			function echarts_seo_chart(){
				//请求数
			}

			//取指定日期的spider详细信息
			function get_spider_bydate(siteName, s_day) {
				var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
				$.post('/plugin?action=a&name=total&s=get_site_total_byday', { siteName: siteName, s_day: s_day, s_type: 'spider' }, function(rdata) {
					layer.close(loadT);
					layer.open({
						type: 1,
						title:'蜘蛛统计',
						area: '800px',
						closeBtn: 2,
						shadeClose: false,
						content: '<div class="bt-form">\
							<div class="bt-w-main">\
								<div class="pd15" id="seo_chart" style="height:550px;width:800px;"></div>\
							</div>\
						</div>'
					});
					var my_flow_chart = echarts.init(document.getElementById('seo_chart'));
					var xData = [],baidu_arry =[],_360_arry = [],google_arry = [],sougou_arry = [],bing_arry = [],yan_arry =[],seo_arry = [],soso_arry = [],yahoo_arry = [],other_arry = [];
					for(var i = 0; i<rdata.length ; i++){
						var all_num =0;
						$.each(rdata[i],function(k,v){
							if(k != "key"){
								all_num += v;
							}	
						})
						
						
						seo_arry.push(all_num);
						
						var s_baidu = s_360 = s_google = s_sogou = s_bing = s_yahoo = s_soso = s_yisou = s_other = 0;
						$.each(rdata[i], function(k, v) {
							if (k == 'key') return;
							if (k.indexOf('Baidu') != -1) {
								s_baidu += v
							} else if (k.indexOf('Yahoo') != -1) {
								s_yahoo += v
							} else if (k.indexOf('360') != -1) {
								s_360 += v
							} else if (k.indexOf('Sogou') != -1) {
								s_sogou += v
							} else if (k.indexOf('Google') != -1) {
								s_google += v
							} else if (k.indexOf('bing') != -1) {
								s_bing += v
							} else if (k.indexOf('Yisou') != -1) {
								s_yisou += v
							} else if (k.indexOf('Soso') != -1) {
								s_soso += v
							} else {
								s_other += v
							}
						});
						
						
						xData.push(rdata[i].key+':00');
						baidu_arry.push(s_baidu);
						_360_arry.push(s_360);
						google_arry.push(s_google);
						sougou_arry.push(s_sogou);
						bing_arry.push(s_bing);
						yan_arry.push(s_yisou);
						soso_arry.push(s_soso);
						yahoo_arry.push(s_yahoo);
						other_arry.push(s_other);

						
					}
					var option = {
						title: {
							text: '蜘蛛统计',
							left: '50%',
							textAlign: 'center',
						},
						tooltip: {
							trigger: 'axis',
							axisPointer: {
								type: 'cross'
							}
						},
						grid:{
							height:'330',
							top:'24%',
						},
						legend: {
							data:['总次数','百度','360','谷歌','搜狗','必应','神马','Yahoo!','Soso','其它'],
							top:'10%'
						},
						xAxis: {
							type: 'category',
							data: xData,
							axisLine:{
								lineStyle:{
									color:"#666"
								}
							}
						},
						yAxis: {
							type: 'value',
							name: '次/h',
							boundaryGap: [0, '100%'],
							splitLine:{
								lineStyle:{
									color:"#ddd"
								}
							},
							axisLine:{
								lineStyle:{
									color:"#666"
								}
							}
						},
						dataZoom: [{
							type: 'inside',
							start: 0,
							end: 100,
							zoomLock:true
						}, {
							start: 0,
							end: 100,
							handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
							handleSize: '80%',
							handleStyle: {
								color: '#fff',
								shadowBlur: 3,
								shadowColor: 'rgba(0, 0, 0, 0.6)',
								shadowOffsetX: 2,
								shadowOffsetY: 2
							}
						}],
						series: [
							{
							 	name:'总次数',
							 	type:'bar',
							 	itemStyle: {
							 		normal: {
							 			color: '#d2e8ff'
							 		}
							 	},
								barMaxWidth:'26px',
							 	data: seo_arry
							},
							{
								name:'百度',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#8dc1a9'
									}
								},
								data: baidu_arry
							},
							{
								name:'360',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#ea7e53'
									}
								},
								data: _360_arry
							},
							{
								name:'谷歌',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#e69d87'
									}
								},
								data: google_arry
							},
							{
								name:'搜狗',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#759aa0'
									}
								},
								data: sougou_arry
							},
							{
								name:'必应',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#eedd78'
									}
								},
								data: bing_arry
							},
							{
								name:'神马',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#33CC99'
									}
								},
								data: yan_arry
							}
							,
							{
								name:'Yahoo!',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#CCCC00'
									}
								},
								data: yahoo_arry
							}
							,
							{
								name:'Soso',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#73a373'
									}
								},
								data: soso_arry
							}
							,
							{
								name:'其它',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#009966'
									}
								},
								data: other_arry
							}
						]
					};
					my_flow_chart.setOption(option,true);

					/****
					 * 以下代码为只统计主要spider和总数
					 * var data = []
					for(var i=0;i<rdata.length;i++){
						var hours = {
							s_total:0,s_baidu:0,s_360:0,s_google:0,s_sogou:0,s_bing:0,s_yahoo:0,s_soso:0,s_yisou:0,s_other:0,s_hour:''
						}
						hours.s_hour = rdata[i].key;
						$.each(rdata[i], function(k,v) {
							if(k=='key') return;
							hours.s_total += v;
							if(k.indexOf('Baidu') != -1){
								hours.s_baidu += v
							}else if(k.indexOf('Yahoo') != -1){
								hours.s_yahoo += v
							}else if(k.indexOf('360') != -1){
								hours.s_360 += v
							}else if(k.indexOf('Sogou') != -1){
								hours.s_sogou += v
							}else if(k.indexOf('Google') != -1){
								hours.s_google += v
							}else if(k.indexOf('bing') != -1){
								hours.s_bing += v
							}else if(k.indexOf('Yisou') != -1){
								hours.s_yisou += v
							}else if(k.indexOf('Soso') != -1){
								hours.s_soso += v
							}else{
								hours.s_other += v
							}
						});
						data.push(hours)
					}
					console.log(data)*/
					//console.log(rdata)
				});
			}

			//客户端
			function AgentStass(siteName) {
				var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
				$.post('/plugin?action=a&name=total&s=get_site_total_byclient', { siteName: siteName }, function(rdata) {
					layer.close(loadT)
					var tbody = '';
					if(rdata == ''){
						tbody = '<tr><td colspan="11">暂无数据</td></tr>'
					}
					for (var i = 0; i < rdata.length; i++) {
						var s_windows = s_android = s_mac = s_iphone = s_wx = s_chrome = s_firefox = s_qq = s_other = 0;
						var s_date = rdata[i].date;
						$.each(rdata[i], function(k, v) {
							if (k == 'date') return;
							if (k == 'Windows') {
								s_windows += v
							} else if (k == 'Android') {
								s_android += v
							} else if (k == 'Mac OS X') {
								s_mac += v
							} else if (k == 'iPhone') {
								s_iphone += v
							} else if (k == 'MicroMessenger') {
								s_wx += v
							} else if (k == 'Chrome') {
								s_chrome += v
							} else if (k == 'Firefox') {
								s_firefox += v
							} else if (k == 'QQBrowser') {
								s_qq += v
							} else {
								s_other += v
							}
						});

						tbody += '<tr>\
										<td>' + s_date + '</td>\
										<td title='+SectionToChinese(s_windows)+'>' + formatCurrency(s_windows) + '</td>\
										<td title='+SectionToChinese(s_android)+'>' + formatCurrency(s_android) + '</td>\
										<td title='+SectionToChinese(s_iphone)+'>' + formatCurrency(s_iphone) + '</td>\
										<td title='+SectionToChinese(s_mac)+'>' + formatCurrency(s_mac) + '</td>\
										<td title='+SectionToChinese(s_wx)+'>' + formatCurrency(s_wx) + '</td>\
										<td title='+SectionToChinese(s_chrome)+'>' + formatCurrency(s_chrome) + '</td>\
										<td title='+SectionToChinese(s_firefox)+'>' + formatCurrency(s_firefox) + '</td>\
										<td title='+SectionToChinese(s_qq)+'>' + formatCurrency(s_qq) + '</td>\
										<td title='+SectionToChinese(s_other)+'>' + formatCurrency(s_other) + '</td>\
										<td><a class="btlink" onclick="get_client_bydate(\'' + siteName + '\',\'' + s_date + '\')">详细</a></td>\
									</tr>';
					}

					var con = '<div class="divtable">\
								<div id="AgentStass_box" style="max-height:515px;overflow:auto;border:#ddd 1px solid">\
								<table class="table table-hover" style="border:none">\
								<thead>\
									<tr>\
										<th>日期</th>\
										<th>Windows</th>\
										<th>Android</th>\
										<th>iPhone</th>\
										<th>Mac</th>\
										<th>微信</th>\
										<th>Chrome</th>\
										<th>火狐</th>\
										<th>QQ</th>\
										<th>其它</th>\
										<th>操作</th>\
									</tr>\
								</thead>\
								<tbody>' + tbody + '</tbody>\
							</table>\
							</div>\
						</div>';
					$(".websitereport").html(con);
					tableFixed("AgentStass_box");
				});
			}


			//取指定日期的客户端详细信息
			function get_client_bydate(siteName, s_day) {
				var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
				$.post('/plugin?action=a&name=total&s=get_site_total_byday', { siteName: siteName, s_day: s_day, s_type: 'client' }, function(rdata) {
					layer.close(loadT)
					console.log(rdata)
					layer.open({
						type: 1,
						title:'SEO统计',
						area: '800px',
						closeBtn: 2,
						shadeClose: false,
						content: '<div class="bt-form">\
							<div class="bt-w-main">\
								<div class="bt-w-menu flow_group">\
									<p class="bgw">终端统计</p>\
								</div>\
								<div class="bt-w-con pd15" id="seo_chart" style="height:550px;width:660px;">\
								</div>\
							</div>\
						</div>'
					});
					var my_flow_chart = echarts.init(document.getElementById('seo_chart'));
					var xData = [],android_arry = [],chrome_arry=[],firefox_arry = [],mac_arry = [] ,weChat_arry = [],window_arry = [],iphone_arry = [] ,all_num =null;
					for(var i = 0; i<rdata.length ; i++){
						for(var j in rdata[i]){
							if(j != 'key'){
								all_num = all_num + parseInt(rdata[i][j]);
							}
						}
						xData.push(rdata[i].key+':00');
						android_arry.push(rdata[i]['Android']);
						chrome_arry.push(rdata[i]['Chrome']);
						firefox_arry.push(rdata[i]['Firefox']);
						mac_arry.push(rdata[i]['Mac OS X']);
						weChat_arry.push(rdata[i]['MicroMessenger']);
						window_arry.push(rdata[i]['Windows']);
						iphone_arry.push(rdata[i]['iPhone']);
					}
					var option = {
						title: {
						    text: '终端访问统计',
						    left: '50%',
						    textAlign: 'center',
						},
						tooltip: {
							trigger: 'axis',
							axisPointer: {
								type: 'cross'
							}
						},
						grid:{
							height:'330',
							top:'24%',
						},
						legend: {
							data:['总类型','Windows','Mac','Android','iPhone','微信','Chrome','Firefox'],
							top:'10%'
						},
						xAxis: {
							type: 'category',
							data: xData,
							axisLine:{
								lineStyle:{
									color:"#666"
								}
							}
						},
						yAxis: {
							type: 'value',
							name: '次/h',
							boundaryGap: [0, '100%'],
							splitLine:{
								lineStyle:{
									color:"#ddd"
								}
							},
							axisLine:{
								lineStyle:{
									color:"#666"
								}
							}
						},
						dataZoom: [{
							type: 'inside',
							start: 0,
							end: 100,
							zoomLock:true
						}, {
							start: 0,
							end: 100,
							handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
							handleSize: '80%',
							handleStyle: {
								color: '#fff',
								shadowBlur: 3,
								shadowColor: 'rgba(0, 0, 0, 0.6)',
								shadowOffsetX: 2,
								shadowOffsetY: 2
							}
						}],
						series: [
							// {
							// 	name:'总类型',
							// 	type:'bar',
							// 	itemStyle: {
							// 		normal: {
							// 			color: '#dd6b66'
							// 		}
							// 	},
							// 	data: seo_arry
							// },
							{
								name:'Windows',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#8dc1a9'
									}
								},
								data: window_arry
							},
							{
								name:'Mac',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#e69d87'
									}
								},
								data: mac_arry
							},
							{
								name:'Android',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#ea7e53'
									}
								},
								data: android_arry
							},
							{
								name:'iPhone',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#ea7e53'
									}
								},
								data: iphone_arry
							},
							{
								name:'微信',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#759aa0'
									}
								},
								data: weChat_arry
							},
							{
								name:'Chrome',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#eedd78'
									}
								},
								data: chrome_arry
							},
							{
								name:'Firefox',
								type:'line',
								smooth:true,
								symbol: 'circle',
								sampling: 'average',
								itemStyle: {
									normal: {
										color: '#73a373'
									}
								},
								data: firefox_arry
							}
						]
					};
					my_flow_chart.setOption(option,true);
				});
			}
			//访问地图
			function AccessMap(siteName){
				var con = '<div class="search-day"><span class="cur" onclick="get_AccessMap(\''+siteName+'\',\'total\')">全部</span><span onclick="get_AccessMap(\''+siteName+'\',\''+getBeforeDate(0)+'\')">今日</span><span onclick="get_AccessMap(\''+siteName+'\',\''+getBeforeDate(1)+'\')">昨日</span><span class="last-span"><input id="date-select" type="text" value=""></span></div><div class="AccessMap-day"></div>';
				$(".websitereport").html(con);
				get_AccessMap(siteName,'total');
				$(".search-day span").not(".last-span").click(function(){
					$(this).addClass("cur").siblings().removeClass("cur");
				})
				laydate.render({
					elem: '#date-select',
					value: new Date(),
					max: 0,
					done: function(value, date, endDate){get_AccessMap(siteName,value);$("#date-select").val(value);$(".last-span").addClass("cur").siblings().removeClass("cur")}
				});
			}
			function get_AccessMap(siteName,day) {
				var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
				$.post('/plugin?action=a&name=total&s=get_site_total_byarea', { siteName: siteName,s_day:day }, function(res) {
						layer.close(loadT);
						var rdata = res.total;
						var tbody ='';
						if(rdata == ''){
							tbody = '<tr><td colspan="4">暂无数据</td></tr>'
						}
						var areaName = '';
						for(var i = 0,len = rdata.length; i < len; i++){
							areaName = rdata[i].area;
							if(areaName == 'other') areaName = '其它';
							tbody += '<tr>\
					 					<td>'+(i+1)+'</td>\
					 					<td>'+areaName+'</td>\
					 					<td title='+SectionToChinese(rdata[i].num)+'>'+formatCurrency(rdata[i].num)+'</td>\
					 					<td>'+rdata[i].percentage+'%</td>\
					 				</tr>'
						}

					 var con = '<div class="divtable">\
					 		<div id="AccessMap_box" style="max-height:470px;overflow:auto;border:#ddd 1px solid">\
							<table class="table table-hover" style="border:none;">\
					 			<thead>\
					 				<tr>\
					 					<th>排行</th>\
					 					<th>省份</th>\
					 					<th>浏览量(pv)</th>\
					 					<th width="100">占比</th>\
					 				</tr>\
					 			</thead>\
					 			<tbody>'+tbody+'</tbody>\
					 		</table>\
							</div>\
					 	</div>';
					 $(".AccessMap-day").html(con);
					 tableFixed("AccessMap_box");
				})
			}

			//接管日志
			function TakeoverLog(siteName) {
				var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
				$.post('/plugin?action=a&name=total&s=get_site_log_days', { siteName: siteName }, function(rdata) {
					layer.close(loadT)
					var days_option = '';
					var day = rdata.days[0];
					if(rdata.days == ''){
						day = getBeforeDate(0);
						days_option ='<option value="'+day+'">'+day+'</option>';
					}
					else{
						for (var i = 0; i < rdata.days.length; i++) {
							days_option += '<option value="' + rdata.days[i] + '">' + rdata.days[i] + '</option>';
						}
					}
					var con = '<div style="margin-bottom:10px"><select class="days_value bt-input-text mr5">' + days_option + '</select><button class="btn btn-default btn-sm va0 btn-del">删除当天日志</button></div>\
							<div class="site-log-open">\
							<span class="pull-left">接管日志</span>\
							<div class="ssh-item pull-right">\
							<input class="btswitch btswitch-ios" id="close_site_log" type="checkbox" '+(rdata.log_open?'checked':'')+'>\
							<label class="btswitch-btn" for="close_site_log" onclick="close_site_log(\''+siteName+'\',\'log_open\')"></label>\
							</div>\
							</div>\
							<div class="data-count"></div>\
							<div class="table-auto-box">\
							<div class="divtable">\
								<table class="table table-hover">\
									<thead>\
										<tr>\
											<th width="150">时间</th>\
											<th>IP</th>\
											<th>类型</th>\
											<th>状态</th>\
											<th>协议</th>\
											<th>URI</th>\
											<th>响应大小</th>\
											<th class="hide">来路</th>\
											<th class="hide">ua</th>\
											<th>详细</th>\
										</tr>\
									</thead>\
									<tbody class="tbodylog"></tbody>\
								</table>\
							</div>\
							<div class="page pull-right" id="size_log_page" style="margin-top:10px"></div>\
							</div>';
					$(".websitereport").html(con);
					var s_day = $(".days_value").val();
					get_log_byday(siteName, day);
					$(".days_value").change(function() {
						s_day  = $(this).val();
						get_log_byday(siteName, s_day);
					});
					$(".btn-del").click(function(){
						del_log_byday(siteName,s_day)
					})
				});
			}
			//接管日志开关
			function close_site_log(siteName,s_key){
				var txt = "是否开启接管日志？";
				var status = $("#close_site_log").prop("checked");
				var that = $("#close_site_log");
				if(status){
					txt = "是否关闭接管日志？"
				}
				layer.confirm(txt,{title:"接管日志开关",icon:3,closeBtn:2,cancel:function(){
					if(status){
						that.prop("checked",true);
					}
					else{
						that.prop("checked",false);
					}
				}}, function() {
					var data= {siteName:siteName,s_key:s_key};
					$.post("/plugin?action=a&name=total&s=set_site_value",data,function(res){
						layer.msg(res.msg,{icon:res.status?1:2})
					})
				},function(){
					if(status){
						that.prop("checked",true);
					}
					else{
						that.prop("checked",false);
					}
				})
				
			}
			
			//删除日志
			function del_log_byday(siteName,s_day,s_status,error_log){
					if(error_log===true){
						var data = {siteName:siteName,s_status:s_status,error_log:error_log};
						var type = s_status;
					}
					else{
						var data = {siteName:siteName,s_day:s_day};
						var type = s_day;
					}
				layer.confirm("您真的清空["+type+"]日志记录吗？",{title:"删除日志["+type+"]",icon:3,closeBtn:2}, function() {
					$.post("/plugin?action=a&name=total&s=remove_site_log_byday",data,function(res){
						layer.msg(res.msg,{icon:res.status?1:2});
						if(error_log===true){
							setTimeout(function(){show_error_log(siteName)},2000)
						}
						else{
							setTimeout(function(){TakeoverLog(siteName)},2000)
						}
					})
				})
			}
			
			//获取日志信息
			function get_log_byday(siteName, s_day,page) {
				var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
				if(!page) page = 1;
				var last = page-1;
				var next = page+1;
				var pagehtml = '';
				var daylogSize = '';
				$.post('/plugin?action=a&name=total&s=get_site_log_byday', { siteName: siteName, s_day: s_day,p:page }, function(res) {
					layer.close(loadT);
					var rdata = res.data;
					var tbody = '';
					daylogSize = '<div class="data-count-box"><p class="dname">当日大小</p><p class="dval"><span>' + ToSize(res.size) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">总大小</p><p class="dval"><span>' + ToSize(res.total_size) + '</span></p></div>'
					for (var i = 0; i < rdata.length; i++) {
						tbody += '<tr title="URI:\n'+rdata[i][5]+'\n\nUser-Agent:\n'+rdata[i][8]+'\n\n来路:\n'+rdata[i][7]+'">\
							<td class="td0">' + rdata[i][0] + '</td>\
							<td class="td1">' + rdata[i][1] + '</td>\
							<td class="td2">' + rdata[i][3] + '</td>\
							<td class="td3">' + rdata[i][4] + '</td>\
							<td class="td4">' + rdata[i][9] + '</td>\
							<td class="td5"><span class="filtertext" title=' + rdata[i][5] + '>' + rdata[i][5] + '</span></td>\
							<td class="td6">' + ToSize(rdata[i][6]) + '</td>\
							<td class="hide td7">' + rdata[i][7] + '</td>\
							<td class="hide td8">' + rdata[i][8] + '</td>\
							<td><a href="javascript:;" class="btlink showtd">详细</a></td>\
						</tr>'
					}
					if(res.data == ''){
						tbody ='<tr><td colspan="8">暂无数据</td></tr>';
					}
					$(".tbodylog").html(tbody);
					$(".data-count").html(daylogSize).show();
					pagehtml = '<a class="Pstart" onclick="get_log_byday(\''+siteName+'\',\''+s_day+'\',1)">首页</a><a class="prevPage" onclick="get_log_byday(\''+siteName+'\',\''+s_day+'\','+last+')">上一页</a><a class="nextPage" onclick="get_log_byday(\''+siteName+'\',\''+s_day+'\','+next+')">下一页</a><a class="Pcount">第 '+page+' 页</a>';
					$("#size_log_page").html(pagehtml);
					if(rdata.length < 1){
						$(".nextPage").hide();
					}
					if(last < 1){
						$(".prevPage").hide();
					}
					$(".showtd").click(function() {
						var td0 = $(this).parents('tr').find(".td0").text();
						var td1 = $(this).parents('tr').find(".td1").text();
						var td2 = $(this).parents('tr').find(".td2").text();
						var td3 = $(this).parents('tr').find(".td3").text();
						var td4 = $(this).parents('tr').find(".td4").text();
						var td5 = $(this).parents('tr').find(".td5").text();
						var td6 = $(this).parents('tr').find(".td6").text();
						var td7 = $(this).parents('tr').find(".td7").text();
						var td8 = $(this).parents('tr').find(".td8").text();
						layer.open({
							type: 1,
							title: td0 + "详情",
							area: '600px',
							closeBtn: 2,
							shadeClose: false,
							content: '<div class="pd15 lib-box">\
										<table class="table" style="border:#ddd 1px solid; margin-bottom:10px">\
										<tbody><tr><th>时间</th><td>' + td0 + '</td><th>客户IP</th><td>' + td1 + '</td><th></th><td></td></tr><tr><th>类型</th><td>' + td2 + '</td><th>状态</th><td>' + td3 + '</td><th>响应大小</th><td>' + td6 + '</td></tr></tbody></table>\
										<div><b style="margin-left:10px">协议</b></div>\
										<div class="lib-con pull-left mt10"><div class="divpre">' + td4 + '</div></div>\
										<div><b style="margin-left:10px">URI</b></div>\
										<div class="lib-con pull-left mt10"><div class="divpre">' + html_decode(td5) + '</div></div>\
										<div><b style="margin-left:10px">来路</b></div>\
										<div class="lib-con pull-left mt10"><div class="divpre">' + html_decode(td7) + '</div></div>\
										<div><b style="margin-left:10px">User-Agent</b></div>\
										<div class="lib-con pull-left mt10"><div class="divpre">' + html_decode(td8) + '</div></div>\
									</div>'
						})
					})
				});
			}


			function show_error_log(siteName) {
				var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
				$.post('/plugin?action=a&name=total&s=get_site_error_logs', { siteName: siteName }, function(rdata) {
					layer.close(loadT);
					var days_option = '';
					var status = rdata[0];
					if(rdata == ''){
						days_option ='<option value="401">401</option><option value="500">500</option>';
					}
					else{
						for (var i = 0; i < rdata.length; i++) {
							days_option += '<option value="' + rdata[i] + '">' + rdata[i] + '</option>';
						}
					}
					var con = '<div style="margin-bottom:10px"><select class="error_log_value bt-input-text mr5">' + days_option + '</select><button class="btn btn-default btn-sm va0 btn-del">删除日志</button></div>\
							<div class="data-count"></div>\
							<div class="divtable">\
								<table class="table table-hover">\
									<thead>\
										<tr>\
											<th width="150">时间</th>\
											<th>IP</th>\
											<th>类型</th>\
											<th>状态</th>\
											<th>协议</th>\
											<th>URI</th>\
											<th>响应大小</th>\
											<th class="hide">来路</th>\
											<th class="hide">ua</th>\
											<th>详细</th>\
										</tr>\
									</thead>\
									<tbody class="tbodyerrorlog"></tbody>\
								</table>\
							</div><div class="page pull-right" id="size_log_page" style="margin-top:10px"></div>';
					$(".websitereport").html(con);
					get_error_log_bystatus(siteName, status,1);
					$(".error_log_value").change(function() {
						status  = $(this).val();
						get_error_log_bystatus(siteName,status);
					});
					$(".btn-del").click(function(){
						del_log_byday(siteName,null,status,true)
					})
					
				});
			}

			function get_error_log_bystatus(siteName, status,page) {
				var loadT = layer.msg('正在获取信息', { icon: 16, time: 0, shade: [0.3, '#000'] });
				if(!page) page = 1;
				var last = page-1;
				var next = page+1;
				var pagehtml = '';
				var daylogSize = '';
				$.post('/plugin?action=a&name=total&s=get_site_log_byday', { siteName: siteName, s_status: status, error_log: 'True',p:page }, function(res) {
					layer.close(loadT);
					var tbody = '';
					var rdata = res.data;
					daylogSize = '<div class="data-count-box"><p class="dname">当日大小</p><p class="dval"><span>' + ToSize(res.size) + '</span></p></div>\
							<div class="data-count-box"><p class="dname">总大小</p><p class="dval"><span>' + ToSize(res.total_size) + '</span></p></div>'
					for (var i = 0; i < rdata.length; i++) {
						tbody += '<tr title="URI:\n'+rdata[i][5]+'\n\nUser-Agent:\n'+rdata[i][8]+'\n\n来路:\n'+rdata[i][7]+'">\
							<td class="td0">' + rdata[i][0] + '</td>\
							<td class="td1">' + rdata[i][1] + '</td>\
							<td class="td2">' + rdata[i][3] + '</td>\
							<td class="td3">' + rdata[i][4] + '</td>\
							<td class="td4">' + rdata[i][9] + '</td>\
							<td class="td5"><span class="filtertext" title=' + rdata[i][5] + '>' + rdata[i][5] + '</span></td>\
							<td class="td6">' + ToSize(rdata[i][6]) + '</td>\
							<td class="hide td7">' + rdata[i][7] + '</td>\
							<td class="hide td8">' + rdata[i][8] + '</td>\
							<td><a href="javascript:;" class="btlink showtd">详细</a></td>\
						</tr>'
					}
					if(rdata == ''){
						tbody ='<tr><td colspan="8">暂无数据</td></tr>';
					}
					$(".tbodyerrorlog").html(tbody);
					$(".data-count").html(daylogSize);
					pagehtml = '<a class="Pstart" onclick="get_error_log_bystatus(\''+siteName+'\',\''+status+'\',1)">首页</a><a class="prevPage" onclick="get_error_log_bystatus(\''+siteName+'\',\''+status+'\','+last+')">上一页</a><a class="nextPage" onclick="get_error_log_bystatus(\''+siteName+'\',\''+status+'\','+next+')">下一页</a><a class="Pcount">第 '+page+' 页</a>';
					$("#size_log_page").html(pagehtml);
					if(rdata.length < 1){
						$(".nextPage").hide();
					}
					if(last < 1){
						$(".prevPage").hide();
					}
					$(".showtd").click(function() {
						var td0 = $(this).parents('tr').find(".td0").text();
						var td1 = $(this).parents('tr').find(".td1").text();
						var td2 = $(this).parents('tr').find(".td2").text();
						var td3 = $(this).parents('tr').find(".td3").text();
						var td4 = $(this).parents('tr').find(".td4").text();
						var td5 = $(this).parents('tr').find(".td5").text();
						var td6 = $(this).parents('tr').find(".td6").text();
						var td7 = $(this).parents('tr').find(".td7").text();
						var td8 = $(this).parents('tr').find(".td8").text();
						layer.open({
							type: 1,
							title: td0 + "详情",
							area: '600px',
							closeBtn: 2,
							shadeClose: false,
							content: '<div class="pd15 lib-box">\
										<table class="table" style="border:#ddd 1px solid; margin-bottom:10px">\
										<tbody><tr><th>时间</th><td>' + td0 + '</td><th>客户IP</th><td>' + td1 + '</td><th></th><td></td></tr><tr><th>类型</th><td>' + td2 + '</td><th>状态</th><td>' + td3 + '</td><th>响应大小</th><td>' + td6 + '</td></tr></tbody></table>\
										<div><b style="margin-left:10px">协议</b></div>\
										<div class="lib-con pull-left mt10"><div class="divpre">' + td4 + '</div></div>\
										<div><b style="margin-left:10px">URI</b></div>\
										<div class="lib-con pull-left mt10"><div class="divpre">' + html_decode(td5) + '</div></div>\
										<div><b style="margin-left:10px">来路</b></div>\
										<div class="lib-con pull-left mt10"><div class="divpre">' + html_decode(td7) + '</div></div>\
										<div><b style="margin-left:10px">User-Agent</b></div>\
										<div class="lib-con pull-left mt10"><div class="divpre">' + html_decode(td8) + '</div></div>\
									</div>'
						})
					})
				});
			}
</script>